"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
exports.__esModule = true;
exports.PrimitiveArray = exports.ClassArray = void 0;
var ClassArray = /** @class */ (function (_super) {
    __extends(ClassArray, _super);
    function ClassArray(clazz) {
        var _this = _super.call(this) || this;
        // tsbug: 编译为es5后，内建类型继承的原型链会发生错误改变。
        Object.setPrototypeOf(_this, ClassArray.prototype);
        _this.elemProto = clazz;
        Object.defineProperty(_this, "elemProto", { enumerable: false });
        return _this;
    }
    // public add(o: object):void {
    //   // o = new this.proto.constructor();
    //   // o = Object.setPrototypeOf(o, <any>this.proto);
    //   this.push(<T><any>o);
    // }
    ClassArray.prototype.newItem = function () {
        return new this.elemProto();
    };
    ClassArray.prototype.addAItem = function () {
        var i = new this.elemProto();
        this.push(i);
        return i;
    };
    return ClassArray;
}(Array));
exports.ClassArray = ClassArray;
var PrimitiveArray = /** @class */ (function (_super) {
    __extends(PrimitiveArray, _super);
    function PrimitiveArray() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return PrimitiveArray;
}(Array));
exports.PrimitiveArray = PrimitiveArray;
